<template>
	<view class="content">
		<image class="logo" src="/static/帅哥.jpg" style="width: 80px;height: 80px; margin: auto;margin-top: 60px;border-radius: 20rpx;"></image>
		<view class="text-area">
			<text class="title">{{title}}</text>
		</view>
		<div style="display: flex;flex-direction: column">
		      <input style="margin: 20rpx;border: 1rpx solid #999999;padding: 20rpx;border-radius: 16rpx;" placeholder="请输入用户名" v-model="from.username"/>
			  <input style="margin: 20rpx;border: 1rpx solid #999999;padding: 20rpx;border-radius: 16rpx;" placeholder="请输入密码" v-model="from.password"/>
			  <input style="margin: 10rpx;float: right: width: 200rpx;height: 150rpx;text-align: right;" placeholder="忘记密码？"/>
		<button  style="background: #007AFF;color: #FFFFFF;width: 710rpx;" @click="deng">登录</button>
			<view class="hade">
				登录即代表你同意<navigator style="color: coral;">用户协议</navigator>和<navigator style="color: coral;">隐私政策</navigator>
			</view>
			<view style="display: flex;flex-direction: row;justify-content: space-between;margin-left: 20rpx;margin-right: 20rpx;">
				<view class="lid">验证码登录</view>
				<view class="zip">注册</view>
			</view>
		</div>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				// title: '',
				from: {
					username: 'user123',
					password: 'user123',
				}
			}
		},
		onLoad() {
		},
		methods: {
			deng(){
				var obj =this.from;
				if(obj.username && obj.password){//判断账号密码是否输入数据
					//账号密码输入进这里
					this.$api.post('/wx/auth/login',this.from).then(res => {
						const data =res.data
						if (data.errno ==0){
							this.$ui.showSuccess("登录成功")
							uni.setStorageSync('user',data.data.token)
							setTimeout(() => {
								uni.switchTab({
									url: '/pages/list/list'
								})
							},1000)
						}else{
							uni.showToast({
								icon:'none',
								title: data.errmsg
							})
						}
					})
				}else{
					uni.showToast({
						title:"信息不能为空"
					})
				}
				// uni.request({
				// 	url:'http://47.91.230.137:8086/wx/auth/login',
				// 	method:'POST',
				// 	data:this.from,
				// 	success:(res) => {
				// 		const data = res.data
				// 		console.log(res)
				// 		if(data.errno == 0){
				// 			uni.reLaunch({ url: '/pages/list/list' })
				// 			uni.setStorageSync('user',data.data.token)
				// 			uni.showToast({
				// 				title:'登录成功',
				// 				icon:'success',
				// 				duration:2000,
				// 				})
				// 		}else {
				// 			uni.showToast({
				// 				icon:'none',
				// 				title:data.errmsg
				// 			})
				// 			// uni.reLaunch({ url: '/pages/list/list' })
				// 		}
				// 	}
				// })
			},
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
	.hade{
		display: flex;
		font-size: 26rpx;
		margin: auto;
	}
	.hbde{
		/* width: 680rpx;
		margin: auto;
		font-size: 30rpx;
		justify-content: space-around;
		flex-direction: row;
		flex-wrap: nowrap;
		justify-content: space-between;
		margin: 20rpx; */
		
	}
</style>
